/*
 * @Description: 
 * @Author: charles
 * @Date: 1985-10-26 16:15:00
 * @LastEditors: charles
 * @LastEditTime: 2021-11-15 16:59:01
 */
import axios from 'axios'
export default {

  namespace: 'article',

  state: {
    data:{list:[]},
    loading:false
  },

  subscriptions: {
    setup({ dispatch, history }) {  // eslint-disable-line
    },
  },
  // 异步 action, 异步获取的数据可以调用commit 【put】来调用同步reducer
  effects: {
    *fetch({ payload }, { put }) {
      let url = "http://121.199.29.84:8002/index/pageQueryArticles"
      let resp = yield axios.get(url,{params:payload});
      //调用同步reducer
      yield put({type:"refreshData",payload:resp.data.data})
    },
  },

  // 同步 mutation
  reducers: {
    refreshData(state, action) {
      return { 
        ...state, 
        data:action.payload
      };
    },
  },

};
